<!DOCTYPE html>
<meta charset="utf-8" />
<link rel="stylesheet" href="ace_v1.3/assets/css/ui.jqgrid.css" />
	<div class="rowt">
		<div class="col-xs-12">
			<table id="grid-table1"></table>

			<div id="grid-pager1"></div>

			<div style="margin-top: 10px">
				</span> <span id="paging_bar1" style="float: right"> </span>
			</div>

			<!-- PAGE CONTENT ENDS -->
		</div>
		<!-- /.col -->
	</div>
	<!-- /.row -->

	<!-- page specific plugin scripts -->
	<script type="text/javascript">
		var jqGrid;
		jQuery(function($) {
			var grid_selector = "#grid-table1";
			var pager_selector = "#grid-pager1";

			$(window).on(
					'resize.jqGrid',
					function() {
						$(grid_selector).jqGrid('setGridWidth',
								$(".page-content").width());
					})
			var parent_column = $(grid_selector).closest('[class*="col-"]');
			$(document).on(
					'settings.ace.jqGrid',
					function(ev, event_name, collapsed) {
						if (event_name === 'sidebar_collapsed'
								|| event_name === 'main_container_fixed') {
							setTimeout(function() {
								$(grid_selector).jqGrid('setGridWidth',
										parent_column.width());
							}, 0);
						}
					})
			jQuery(grid_selector).jqGrid({

				url : "mpomng/custAccountManage/queryList.do",
				datatype : "json",
				height : '100%',
				width : '100%',
				colNames : [ '商户编号', '账户编号','账户类型', '货币类型','总余额','T+0', 'T+1','T+1未提','冻结金额','最后交易时间','是否冻结','操作' ],
				colModel : [ {name : 'custId',     index : 'custId',     width : '220px' }, 
				             {name : 'account',       index : 'account',       width : '150px' }, 
				             {name : 'acType',     index : 'acType',     width : '150px' , ditcKey:'ACTYPE', formatter : gridFormatByDict},
				             {name : 'ccy',    index : 'ccy',    width : '150px' ,ditcKey:'CERTIFICATETYPE' ,formatter : gridFormatByDict}, 
				             {name : 'acBal',   index : 'acBal',   width : '150px' }, 
				             {name : 'acT0',  index : 'acT0',   width : '150px'}, 
				             {name : 'acT1',   index : 'acT1',   width : '150px' }, 
				             {name : 'acT1Y',   index : 'acT1Y',   width : '150px' }, 
				             {name : 'frozBalance',    index : 'frozBalance',    width : '150px'}, 
				             {name : 'lstTxDatetime',         index : 'lstTxDatetime',         width : '150px' ,formatter : dateFormat}, 
				             {name : 'accountStatus',    index : 'accountStatus',    width : '150px' ,ditcKey:'ACSTATUS' ,formatter : gridFormatByDict}, 
				             {name : 'op',  index : 'op',  width : '150px' ,formatter:operateEdit}
				            ],
				viewrecords : true,
				rowNum : 10,
				rowList : [ 12, 20, 30 ],
				altRows : true,
				shrinkToFit : false,
				multiselect : true,//设置行可多选的 
				multiboxonly : true,//

				loadComplete : function() {
					var table = this;
					setTimeout(function() {
						//加载分页
						initPagingBar(grid_selector);
					}, 0);
				},
				beforeRequest : function() {//请求之前执行
					jqGrid = this;
				},
			});
			$(window).triggerHandler('resize.jqGrid');

			$(document).one('ajaxloadstart.page', function(e) {
				$(grid_selector).jqGrid('GridUnload');
				$('.ui-jqdialog').remove();
			});

			function operateEdit(cellvalue, options, rowObject){// "<div class='hidden-phone visible-desktop btn-group'>"
				var status=rowObject["accountStatus"];
				if(status=='0'){
					var button = "<div class=\"hidden-sm hidden-xs btn-group\">";  //定义button
					button += "<button class='btn btn-xs btn-warning'  title='详细信息查看'>冻结</button>";
				}else{
					var button = "<div class=\"hidden-sm hidden-xs btn-group\">";  //定义button
					button += "<button class='btn btn-xs btn-warning'  title='详细信息查看'>解冻</button>";
				}
				
				return button;
			}
			//格式化日期
			function dateFormat(cellvalue, options, rowObject){
				return getDateFormat(rowObject["lastOperTime"]);
			}
		});

		
		function selectAccount(custId) {
			if(custId.length<=0){
				msg.alert("警告", "当前没有选择数据项！", "error");
				return;
			}
			var scrWidth = document.body.scrollWidth;
			openDialog({
				dialogId : 'dlg-agentEdit',
				title : '商户实名认证信息详情',
				pageUrl :'mpomng/custAccountManage.do',
				dataUrl : 'mpomng/custAccountManage/queryList.do',
				width :  scrWidth*0.8,
				dataParam : {
					custId : custId,
				},
				dataName : 'obj,map'//表单数据存储对象名称
			});
		}
		
	    function statusUpdate0(){
	    	setUserStatus(0);
	    }
	    function statusUpdate1(){
	    	setUserStatus(1);
	    }
		function setUserStatus(status){
			var rows = $('#grid-table').jqGrid("getGridParam", "selarrrow");
			if (rows.length == 0) {
				msg.alert("警告", "当前没有选择的数据项,请选择数据！", "warn");
				return;
			}
			
			var ids="",uname="";
			var rowData ;
			for(var i=0; i<rows.length; i++){
				rowData = $('#grid-table').jqGrid('getRowData',rows[i]);
				ids   = ids+rowData.custId+",";
				uname = uname + rowData.custName+",";
			}
			ids   = ids.substring(0, ids.lastIndexOf(","));
			uname = uname.substring(0, uname.lastIndexOf(","));
			var tmsg = "启用";
			if(status == 1){
				tmsg = "禁用";
			}
			
			msg.confirm({title:'确认',position:'center',msg:'您确定要'+tmsg+'商户['+uname+']吗？',call:function(ok){
				if(ok){
					$.ajax({
						type : "post",
					    url : "mpomng/mobileMerManage/modifyCustStatus.do?status="+status+"&ids="+ids,
						dataType : 'json',
						success : function(result) {
							if (result.rspcod != 200) {
								msg.alert("错误", result.rspmsg + " 错误代码："
										+ result.rspcod, 'error');
							} else {
								msg.alert("提示", result.rspmsg, 'correct');
								$("#grid-table").trigger("reloadGrid");
							}
						},
						error : function(XMLHttpRequest, textStatus) {
							msg.alert("错误", "错误代码：" + XMLHttpRequest.status + ",错误描述："
									+ textStatus, 'error');
						}
					});

				}
			}});
			
		}
		
	function report(){
		var sdate = "00000000";
		var edate = "99999999";
		var param = "";
		
		msg.confirm({title:'确认',position:'center',msg:'确认导出当前数据吗？',call:function(ok){
			if(ok){
				$.ajax({
					type : "post",
				    url : "mpomng/mobileMerManage/report.do?"+param,
					dataType : 'json',
					success : function(result) {
						if (result.rspcod != 200) {
							msg.alert("错误", result.rspmsg + " 错误代码："
									+ result.rspcod, 'error');
						} else {
							msg.alert("提示", result.rspmsg, 'correct');
						}
					},
					error : function(XMLHttpRequest, textStatus) {
						msg.alert("错误", "错误代码：" + XMLHttpRequest.status + ",错误描述："
								+ textStatus, 'error');
					}
				});
			}
		}});
	}
	
	</script>